from selenium import webdriver
from guoqingzuoye3.Base import Base
import openpyxl
import pytest

@pytest.fixture()
def driver():
    driver=webdriver.Chrome()
    driver.maximize_window()
    driver.switch_to.window(driver.window_handles[-1])
    yield driver
    driver.quit()

def test_01(driver):
    work=openpyxl.load_workbook('jiuxian.xlsx')
    excel=work['Sheet1']
    base=Base(driver)
    for row in excel.iter_rows(min_row=2,values_only=True):
        action=row[2]
        p={}
        if action=='open_browser':
            p['browser_type']=row[5]
        elif action=='open_url':
            p['url']=row[5]
        elif action in ['send_keys','click','text']:
            p['loc']=[row[3],row[4]]
            if action=='send_keys':
                p['info']=row[5]
        elif action=='sleep':
            p['s']=row[5]

        method=getattr(base,str(action))
        method(**p)